<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head>
	<th:block th:include="include :: header('泵站详情')" />
</head>
<body>
    <div class="container-div">
    <input name="psId" autocomplete="off" id="psId"  class="form-control" type="hidden" th:value="${pumpStationInfo.id}" >
    	<div class="row">
    		 <div th:include="biz/pumpStation/include::detail-header"></div>
    		 <div class="col-sm-12">
    			<!-- <ul id="navTabs" class="nav nav-tabs">
				    <li class="active"><a href="#unitList" data-toggle="tab">供水单位列表</a></li>
				    <li><a href="#relaList" data-toggle="tab">管理者列表</a></li>
				</ul> -->
				<div id="tabContent" class="tab-content">
				    <!--<div class="tab-pane in active"id="unitList">-->
				    	<!--<div class="btn-group-sm" id="toolbar" role="group">-->
							<!--<a class="btn btn-success" onclick="addUnit()" shiro:hasPermission="biz:unit:add">-->
								<!--<i class="fa fa-plus"></i>添加供水单位-->
							<!--</a>-->
						<!--</div>-->
						<!--<table id="unit-table" data-mobile-responsive="true"></table>-->
				    <!--</div>-->
				    <!--<div class="tab-pane" id="relaList"   >-->
				    	<!--<div class="btn-group-sm"id="video-toolbar" role="group">-->
							<!--<a class="btn btn-success" onclick="addRela()" shiro:hasPermission="biz:sur:add">-->
								<!--<i class="fa fa-plus"></i>  添加管理者-->
							<!--</a>-->
						<!--</div>-->
				    	<!--<table id="rela-table" data-mobile-responsive="true"></table>-->
				    <!--</div>-->

				    <!--<div class="tab-pane" id="elementList"   >-->
				    	<!--<div class="btn-group-sm"id="element-toolbar" role="group">-->
							<!--<a class="btn btn-success" onclick="addElement()" shiro:hasPermission="biz:sur:add">-->
								<!--<i class="fa fa-plus"></i>  添加泵站组件-->
							<!--</a>-->
						<!--</div>-->
				    	<!--<table id="element-table" data-mobile-responsive="true"></table>-->
				    <!--</div>-->

				    <!--<div class="tab-pane" id="alermtList"   >-->
				    	<!--<div class="btn-group-sm"id="alerm-toolbar" role="group">-->
							<!--<a class="btn btn-success" onclick="addalerm()" shiro:hasPermission="biz:sur:add">-->
								<!--<i class="fa fa-plus"></i>  添加泵站告警规则-->
							<!--</a>-->
						<!--</div>-->
				    	<!--<table id="alerm-table" data-mobile-responsive="true"></table>-->
				    <!--</div>-->

				</div>



    		</div>
    	</div>
	</div>
    <div th:include="include::footer"></div>
    <script th:inline="javascript">
    	var prefix = ctx + "biz/unit";
    	var editFlag = [[${@permission.hasPermi('biz:unit:edit')}]];
        var removeFlag = [[${@permission.hasPermi('biz:unit:remove')}]];
        var types = [[${@dict.getType('sys_normal_disable')}]];
        var datas = [[${@dict.getType('biz_is_delete')}]];
        
        function addUnit(){
        	var url = prefix + '/add?stationId='+[[${pumpStationInfo.id}]]+'&stationName=' + [[${pumpStationInfo.pumpName}]];
        	$.modal.open('添加供水单位', url);
        }

        function addRela(){
        	var url = ctx + 'biz/stationUserRelation/addUser?stationId='+[[${pumpStationInfo.id}]]+'&stationName=' + [[${pumpStationInfo.pumpName}]];
        	$.modal.open('添加管理者', url);
        }
        
        $(function() {
            var options = {
            	id: "unit-table",
                url: prefix + "/list/"+[[${pumpStationInfo.id}]],
                createUrl: prefix + "/add",
              //  updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "泵站供水单位",
                columns: [
				{
					field : 'id', 
					title : 'ID' 
				},
				// {
				// 	field : 'name',
				// 	title : '供水单位名称'
				// },
				 {
					field : 'pumpName',
					title : '泵站名称'
				},
				{
					field : 'lng', 
					title : '经纬度',
					formatter: function(value, row, index) {
		            	return row.lat + ',' + row.lng;
		            }
				},
				{
		            field: 'isValid',
		            title: '是否有效',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	return statusTools(row);
		            }
		        },
				{
					field : 'createBy', 
					title : '创建者' 
				},
				{
		            field: 'createTime',
		            title: '创建时间',
		            sortable: false
		        },
		        {
		            field: 'remark',
		            title: '备注'
		        },
		        /* {
					field : 'updateBy', 
					title : '更新者' 
				},
				{
		            field: 'updateTime',
		            title: '更新时间',
		            sortable: true
		        }, */
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="editUnit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        
        
        function editUnit(id){
        	var url = prefix + '/edit/'+id+"?type=1";
        	$.modal.open('修改供水单位', url);
        }
        
        function statusTools(row) {
		    if (row.isValid == 0) {
    			return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
    		} else {
    			return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
    		}
		}
		
		function disable(id) {
			$.modal.confirm("确认要失效吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
		    })
		}

		function enable(id) {
			$.modal.confirm("确认要启用吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
		    })
		}
    	
    </script>
</body>
</html>
